//
//  YMath.h
//  yuikemall
//
//  Created by yuike6 yuike6 on 12-2-22.
//  Copyright (c) 2012年 yuike. All rights reserved.
//
#import <Foundation/Foundation.h>

@interface YFloatRange : NSObject {
    float a;
    float b;
}
@property (nonatomic, assign) float a;
@property (nonatomic, assign) float b;
+(YFloatRange*)floatRange;
@end



@interface YMath : NSObject
+ (int)getRandomNumber:(int)from to:(int)to;


+ (CGSize) SizeScalingProportionallyToMinimumSize : (CGSize) rect 
                                    targetSize:(CGSize) targetSize;

+ (YFloatRange*) parseFloatRange:(NSString*)str;
//+ (void) parseFloatRangeTest;

+ (double) triangleArea:(CGPoint) point1 point2:(CGPoint) point2 point3:(CGPoint) point3;

/*
 
 */
+ (double) polygonArea:(CGPoint) firstPoint, ...;
+ (double) polygonArea:(const CGPoint[]) points count:(NSInteger)count;

+ (double) polygonAreaWithPointArray:(NSMutableArray *) points;

+ (BOOL) pointIsInTriangle:(CGPoint) targetPoint 
        withTrianglePoint1:(CGPoint) trianglePoint1 
        withTrianglePoint2:(CGPoint) trianglePoint2 
        withTrianglePoint3:(CGPoint) trianglePoint3;

+ (BOOL) pointIsInEllipse:(CGPoint) targetPoint 
                 ellipseA:(CGFloat) a 
                 ellipseB:(CGFloat) b 
              isFocusPointAtXAxis:(BOOL) xAxis
              centerPoint:(CGPoint) centerPoint;

+ (BOOL) pointIsInPolygonArea:(CGPoint) targetPoint, ...;


+ (CGPoint) rotatePoint:(CGPoint) point radian:(double) radian;

+ (CGPoint) rotatePoint:(CGPoint) point radian:(double) radian withRotatePoint:(CGPoint) rotatePoint;

+ (float) spaceTwoPoint:(CGPoint) point1 point2:(CGPoint) point2;



+ (float) radina2Angle:(float) radina;
+ (float) angle2Radina:(float) angle;


/*
 两条直线的交点
 */
+(CGPoint) crossPoint:(CGPoint) point1
               point2:(CGPoint) point2
               point3:(CGPoint) point3 
               point4:(CGPoint) point4;

@end


/*
 if (downloadSize == 1) {
 result = @"1 byte";
 } else if (downloadSize < 1024) {
 result = [NSString stringWithFormat:@"%f bytes", downloadSize];
 } else if (downloadSize < (1024.0 * 1024.0 * 0.1)) {
 result = [self _stringForNumber:downloadSize / 1024.0 asUnits:@"KB"];
 } else if (downloadSize < (1024.0 * 1024.0 * 1024.0 * 0.1)) {
 result = [self _stringForNumber:downloadSize / (1024.0 * 1024.0) asUnits:@"MB"];
 } else {
 result = [self _stringForNumber:downloadSize / (1024.0 * 1024.0 ) asUnits:@"MB"];
 }

 */